﻿@model Easy.CMS.List.ViewModel.ListTops_Common_ViewModel
@using Easy.Web.CMS.Data;
@{
    Script.Reqiured("List").AtHead();

    if (!Model.Widget.DetailPageUrl.IsNullOrEmpty())
    {
        Model.Widget.DetailPageUrl = Url.Content(Model.Widget.DetailPageUrl);
    }
}

<style>
    .listtops {
        font-size:14px;
    }
    .list-group-item{
        padding: 6px 10px;
    }
</style>

<script>
    $(function () {
        var shortWidth = $(".media-list").width() - 10;
        $(".shorttext").css("width", shortWidth + "px");
    })
</script>

<div id="listtops" class="listtops">
    <ul class="list-group">
        @if (!Model.JsonResult.IsNullOrEmpty() && Model.Columns != null && Model.Columns.Count > 0)
        {
            var data = Json.Decode(Model.JsonResult);
            foreach (var item in data)
            {
                string Id = item["Id"].ToString();
                string title = !Model.Columns[0].IsNullOrEmpty()? @item[Model.Columns[0]]:string.Empty;
                string date = !Model.Columns[1].IsNullOrEmpty() ? @item[Model.Columns[1]] : string.Empty;
                
                <a title="@title" class="list-group-item" href="@Url.PathContent(Url.ListDetailUrl(Model.Widget.DetailPageUrl, Id))" target="_blank">
                    <li style="overflow-x: hidden;text-overflow: ellipsis;white-space: nowrap;">
                        <span class="list-group-item-text">
                             @title.GetSubString(Convert.ToInt32(@Model.Widget.ItemLength))
                        </span>
                        <span class="right_time">
                            @date
                        </span>
                    </li>
                </a>
            }
        }
    </ul>
</div>